/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ace.game.entity.body;

import ace.game.Sprite;
import ace.system.Utilities;
import ace.system.xml.XmlNode;

/**
 *
 * @author Hallucinogen
 */
public class BodyData {
	protected BodyData() {
		mVelocity		= 0;
		mHealthMax		= 1;

		mSprites	= null;
	}

	public BodyData(XmlNode xml) {
		//Initialize
		this();

        // set index
        mIndex  = Integer.parseInt(xml.getAttribute("index"));

		//Prepare variable
		XmlNode imageNode	= null;

		//For each node
		for(int i=0; i < xml.getChildren().size(); ++i) {
			//Get tag name and it's value
			String Tag		= ((XmlNode)xml.getChildren().elementAt(i)).getNodeName();
			String Value	= ((XmlNode)((XmlNode) xml.getChildren().elementAt(i)).getChildren().elementAt(0)).getNodeValue();

			//Save data
			if (Tag.equals("name"))				mName           = Value;
            else if (Tag.equals("description")) mDescription    = Value;
			else if (Tag.equals("price"))       mPrice          = Integer.parseInt(Value);
			else if (Tag.equals("velocity"))	mVelocity       = Integer.parseInt(Value);
			else if (Tag.equals("sprite"))		imageNode       = (XmlNode)xml.getChildren().elementAt(i);
			else if (Tag.equals("health"))		mHealthMax      = Integer.parseInt(Value);
			else if (Tag.equals("body-size"))	mBodySize       = Integer.parseInt(Value);
		}

		//Create sprite
		if (imageNode != null) {
			mSprites = new Sprite(imageNode, Utilities.BODY_FOLDER);
		}
	}


	public String getName()         { return mName;			}
    public String getDescription()  { return mDescription;  }
	public int getHealthMax()       { return mHealthMax;	}
	public float getVelocity()      { return mVelocity;		}
	public Sprite getSprites()      { return mSprites;		}
    public int getBodySize()        { return mBodySize;     }
    public int getPrice()           { return mPrice;        }
    public int getIndex()           { return mIndex;        }

	private String  mName;
    private String  mDescription;
    private int     mHealthMax;
	private float	mVelocity;
    private int     mBodySize;
    private int     mPrice;
    private int     mIndex;

	//Images
	private Sprite mSprites;
}
